package com.lawcheukwing.MagicDroidMouse;

import java.lang.reflect.Array;
import java.util.ArrayList;

import android.app.Activity;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Context;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;

public class AboutActivity extends ListActivity {
	AboutAdapter aa;
	
	public AboutActivity() {
		super();
		
	}
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		aa = new AboutAdapter(this);
		this.setListAdapter(aa);
	}
	
	private class AboutAdapter implements ListAdapter {
		public View[] views = new View[3];
		
		public AboutAdapter(Context context){
			super();
			views[0] = getLayoutInflater().inflate(R.layout.about, null);
			views[1] = getLayoutInflater().inflate(R.layout.third_party_software, null);
			views[2] = getLayoutInflater().inflate(R.layout.license, null);
		}

		@Override
		public int getCount() {
			return views.length;
		}

		@Override
		public Object getItem(int position) {
			return views[position];
		}

		@Override
		public long getItemId(int position) {
			return 0;
		}

		@Override
		public int getItemViewType(int position) {
			return IGNORE_ITEM_VIEW_TYPE;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			return views[position];
		}

		@Override
		public int getViewTypeCount() {
			return 1;
		}

		@Override
		public boolean hasStableIds() {
			return false;
		}

		@Override
		public boolean isEmpty() {
			return views.length == 0;
		}

		@Override
		public void registerDataSetObserver(DataSetObserver observer) {
			// TODO Auto-generated method stub
		}

		@Override
		public void unregisterDataSetObserver(DataSetObserver observer) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public boolean areAllItemsEnabled() {
			boolean tmp = true;
			if(isEmpty() == false){
				for(int i = 0; i < views.length; i++){
					tmp = views[i].isEnabled();
					if(tmp == false){
						break;
					}
				}
			}
			return tmp;
		}

		@Override
		public boolean isEnabled(int position) {
			return views[position].isEnabled();
		}
		
	}
}
